import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;


public class FDSds {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    try {  
	    	String cmdStr[]=new String[2];
	    	cmdStr[0]= "javac" ;
	    	cmdStr[1]= "?/help \r\n" ;
	       // String cmdStr[]=new String[6];
	      //  cmdStr[0]= "cmd /k" ;  
	      //  cmdStr[1]= "ipconfig /all \r\n" ;  
	      //  cmdStr[2]="netstat -an \r\n";
	     //   cmdStr[3]="nslookup www.baidu.com \r\n";
	     //   cmdStr[4]="ping www.baidu.com \r\n";
	     //   cmdStr[5]="telnet \r\n";
	        
	        Process p=Runtime.getRuntime().exec(cmdStr[0]);
	        MyThread1 n=new MyThread1(p);
	        n.start();
	        Thread.sleep(1000);
	        OutputStream ou=p.getOutputStream();
	        int t=1;
	        while(t<cmdStr.length){
	        	char[] c=cmdStr[t].toCharArray();
	        	 int i=0;
	           while(i<c.length){
	              ou.write((int)c[i]);
	              i++;
	           }   
	           ou.flush();
	        
	           Thread.sleep(1000);
	          t++; 
	        }   

	    }catch(Exception e){  
	        e.printStackTrace();  
	    }  
	}

}

class MyThread1 extends Thread{
	public Process p=null;
	public MyThread1(Process p){
		this.p=p;
	}
	public void run(){
		InputStream in=p.getInputStream(); 
		int b=0;
        try {
        	while(true){
			   while((b=in.read())>0){
		 		   System.out.print((char)b);
			   }
        	}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
